MAIN.C
void main(void)
{
...
for (;;) {
Bit1_NegVal(); // Invert output level on the pin
}
...
}
(3) This example emulates an open drain output pin. The direction of the bean is set to input/output
and the safe mode is disabled. External pull-up resistor should be connected to the pin.
MAIN.C
void main(void)
{
...
/* Set input mode. */
Bit1_SetDir(FALSE);
/* Logical "1" is on the pin */
...
/* Set output mode */
Bit1_SetDir(TRUE);
/* Set output value to "0" */
Bit1_ClrVal();
/* Logical "0" is on the pin */
...
}
(4)
This example shows how the value written to the bean when it is set to the input direction is
written to the output after the direction is switched to output.
The safe mode is enabled and an external pull-up resistor should be connected to the pin.
MAIN.C
void main(void)
{
...
/* Set input mode */
Bit1_SetDir(FALSE);
/* Logical "1" is on the pin */
/* Set output value to "0", which will be
applied when the bean will be set to output mode */
Bit1_ClrVal();
/* Set output mode */
Bit1_SetDir(TRUE);
/* Logical "0" is on the pin */
...
}
For more about typical usage of the bean code please refer to the page Bean Code Typical Usage.